package com.zzc.emotisenseclassroom.utils;

import com.zzc.ZzcException.IllegalInstantiationException;

import java.util.Calendar;
import java.util.Date;

/**
 * Copyright Zzc
 * FileName: DateUtil
 * Author:   Zzc
 * Date:     2024/5/421:40
 * Description:时间工具类
 * hISTORY:
 * <author>  <time>     <version>    <desc>
 * 作者姓名   修改时间       版本号       描述
 * Zzc                   1.0.0
 */
public class DateUtil {
    private DateUtil(){
        // 禁止实例化
        throw new IllegalInstantiationException();
    }

    public static Date removeTime(Date date) {
        // 创建 Calendar 实例
        Calendar calendar = Calendar.getInstance();
        // 将 Date 设置为 Calendar
        calendar.setTime(date);
        // 将时间部分设置为 0
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        // 将 Calendar 转换回 Date
        return calendar.getTime();
    }
}
